﻿using LuceneApiServerLib;
using LuceneNetHelper;

namespace WebApplication1
{
    public class Class1
    {
        private static readonly Lucene<Article> client = new Lucene<Article>("Index_Article",
           false?"http://127.0.0.1:8088/ApiService":
            "http://wechat.hznzcn.com/lucene/web/api/ApiService", "admin", "123456");

        #region 单例

        private static readonly object Lock = new object();

        private bool isCreate = false; //存在索引库文件夹以及索引库特征文件false 

        private Class1()
        {
            //var s= connect().Result;
        }

        //private  async Task<bool> connect()
        //{
        //    var state = await client.Connect("192.168.2.251", 8088);
        //    if (state)
        //    {
        //      return await client.Login("admin", "hznzcn123456");
        //    }
        //    return false;
        //}


        private static Class1 _instance;

        /// <summary>
        ///     单例
        /// </summary>
        public static Class1 Instance
        {
            get
            {
                if (
                    _instance != null) return _instance;
                lock (Lock)
                {
                    if (_instance == null)
                    {
                        _instance = new Class1();
                    }
                }
                return _instance;
            }
        }

        public Lucene<Article> getclient
        {
            get { return client; }
        }

        #endregion
    }
}